function 'getURL()' seems to work only once

Hi,

While running a dxl script i was noting the fact that the function 'getURL' seemed to work only once.
My code looks like this(i've shortened it a bit to make it easier to read):
 

pragma runLim,0
 
#include <utils/helpers.inc>
 
 
string logFilename      = "D:\\xx.log"
Stream logfile          = append(logFilename)
logfile << dateAndTime(today) " #start\n"
 
string targetFolder
 
bool hasExtLink  = false
 
Buffer sourceURL = create
 
Object o
Object sourceObject
 
//*****************************************************************************************************************************
void findSourceObject(Link l) {
 
    sourceObject = source (l)
        sourceURL = getURL(sourceObject)
}
//*****************************************************************************************************************************
//*****************************************************************************************************************************
void processModule(string moduleName) {
 
        m = edit(moduleName, false)
        logfile << dateAndTime(today) " now processing module '" moduleName "'\n"
                
        for o in entire m do {                
                                
                sourceURL = ""
                
                
                openSourceModules(o)
                                                        
                Link lnk
                for lnk in o <- "*" do if (prefixCorrect(module source (lnk), "TRS")) if (moduleHasAttribute(module source (lnk), "xx")) findSourceObject(lnk)         
                        
                //check if external link to sourceObject already exists
                logfile << dateAndTime(today) " LS '" fullName(m) "' '" o."Absolute Number" "' linkString is '" tempStringOf(sourceURL) "'\n"
                if (tempStringOf(sourceURL) != "") {
                                                
                        hasExtLink = false
                        
                        ExternalLink el
                        for el in o -> "*" do hasExtLink = true
                        
                        //if not: create external link to sourceObject
                        if (!hasExtLink) {
                                create(o, "sourceObject", "dailyUpdate.sourceLink", outward, openAsURL, tempStringOf(sourceURL), el)
                                logfile << dateAndTime(today) " L  '" fullName(m) "' '" o."Absolute Number" "' Create ExtLink to '" sourceURL "'\n"
                        }//end if (!hasExtLink)
                        
                }//end if (tempStringOf(sourceURL) != "")
                                                
        
        }//end for object in entire module
        save (m)
        close(m)
}
//*****************************************************************************************************************************
//*****************************************************************************************************************************
 
        Item i
        for i in folder targetFolder do if (type(i) == "Formal") processModule (fullName(i))
 
        closeAllModules()
}// end read config
//*****************************************************************************************************************************
 
delete(sourceURL)
 
 
logfile << dateAndTime(today) " #stop dailyUpdate\n"
 
flush(logfile)
close(logfile)

 


The logfile entry LS gives me for the first processed object:
05/04/10 10:31:21 LS '/x/x/x' '1098' linkString is 'doors://oekawsdo03.hbi.ad.harman.com:36677/?version=2&prodID=0&view=00000004&urn=urn:telelogic:7db02610-4945-11df-a300-79500921a422:1-403f20f05b213b1a-O-2255-0000ee05'
and for all objects processed after this an emtpy linkString:
05/04/10 10:31:22 LS '/x/x/x' '847' linkString is ''

Any ideas on this?
btw i get no dxl errors..

Regards,
Manuel

 


ManuelFelger - Tue May 04 04:43:38 EDT 2010

Re: function 'getURL()' seems to work only once
llandale - Tue May 04 17:44:24 EDT 2010

Lets assume the missing functions do what they appear to do.

If you add parameter 'Object o' to function <findSourceObject(Object o, Link l)>, and inside issue a
print ">>findSourceObject " (identifier(o) "\tURL <">\n"

I think you will find that function findSourceObject isn't getting called very often, and the URL is null because you correctly set it to null in your loop. Maybe those other objects don't have many qualifying incoming links.

On other news...

You don't need sourceURL in a Buffer. Using a string variable doesn't add to the string table more than once, but manipulating does.

You are only getting the URL for the last incoming link to an object o; seems to me you'd want an external link for all of ..err.. each of them.

It appears I'm the only person who hates those run-on clauses:
for bla in bla do if (bla) if (also bla) for bla in bla do bla

Auto Declare in on, tsk tsk tsk. Look for 'AutoDeclareSet.dxl' to switch it on and off.

  • Louie